<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>众智天成后台管理</title>
	<!-- Tell the browser to be responsive to screen width -->
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<!-- Bootstrap 3.3.6 -->
	<link rel="stylesheet" href="/plugin/AdminLTE-2.3.11/bootstrap/css/bootstrap.min.css">
	<!-- Font Awesome -->
	<link rel="stylesheet" href="/plugin/Font-Awesome-4.7.0/css/font-awesome.min.css">
	<!-- Ionicons -->
	<link rel="stylesheet" href="/plugin/ionicons-2.0.1/css/ionicons.min.css">
	<!-- Theme style -->
	<link rel="stylesheet" href="/plugin/AdminLTE-2.3.11/dist/css/AdminLTE.min.css">
	<!-- iCheck -->
	<link rel="stylesheet" href="/plugin/AdminLTE-2.3.11/plugins/iCheck/square/blue.css">

	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
	<script src="/plugin/html5shiv-3.7.3/dist/html5shiv.min.js"></script>
	<script src="/plugin/Respond-1.4.2/dest/respond.min.js"></script>
	<![endif]-->
</head>
<body class="hold-transition login-page">
<div class="login-box">
	<div class="login-logo">
		<a href="/manage"><b>众智天成</b>管理系统</a>
	</div>
	<!-- /.login-logo -->
	<div class="login-box-body">
		<p class="login-box-msg">欢迎光临，请先登录。</p>

		<form action="/manage/login" method="post">
			{{csrf_field()}}
			<div class="form-group has-feedback">
				<input type="text" class="form-control" name="username" placeholder="用户名/邮箱">
				<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
			</div>
			<div class="form-group has-feedback">
				<input type="password" name="password" class="form-control" placeholder="密码">
				<span class="glyphicon glyphicon-lock form-control-feedback"></span>
			</div>
			<div class="row">
				<div class="col-xs-8">
					<div class="form-group has-feedback">
						<input name="captcha" type="text" class="form-control" placeholder="验证码" minlength="3" maxlength="5" required>
					</div>
				</div>
				<!-- /.col -->
				<div class="col-xs-4">
					<img id="captcha" src="captcha" onclick="this.src='captcha?'+Math.random()" style="cursor:pointer" alt="点击刷新验证码" title="点击刷新验证码">
				</div>
				<!-- /.col -->
			</div>
			<div class="row">
				<!-- /.col -->
				<div class="col-xs-12">
					<button type="submit" class="btn btn-primary btn-block btn-flat">登录</button>
				</div>
				<!-- /.col -->
			</div>
		</form>
	</div>
	<!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<!-- jQuery 3.2.1 -->
<script src="/plugin/jquery-3.2.1.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/plugin/AdminLTE-2.3.11/bootstrap/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="/plugin/AdminLTE-2.3.11/plugins/iCheck/icheck.min.js"></script>
{{--layer--}}
<script src="/plugin/layer-v3.0.3/layer/layer.js"></script>
<script>
	$(function () {
		//提交表单
		$("form").submit(function(event) {
			event.preventDefault();
			var url = $(this).attr("action");
			$.ajaxSetup({
				headers: {
					'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
				}
			});
			$.ajax({
				url: url,
				type: "POST",
				data: $("form").serialize(),
				dataType: "json",
				success: function(data) {
					console.log(data);
					if(data.code == 100) {
						layer.msg(data.msg);
						window.location.href = "/manage";
					}
					else {
						if (data.code == 102) {
							$("#captcha").click();
							$("input[name='captcha']").select();
						}
						layer.msg(data.msg);
					}
				}
			});
		});
	});
</script>
</body>
</html>
